﻿namespace Webinator.ExtensionMethods
{
    using System;

    /// <summary>
    /// Useful extension methods.
    /// </summary>
    public static class IntExtensions
    {
        /// <summary>
        /// Asserts that the specified int value matches the expected value.
        /// </summary>
        /// <param name="value">The int value to assert.</param>
        /// <param name="expected">The expected int value.</param>
        public static void AssertCount(this int value, int expected)
        {
            AssertCount(value, expected, string.Empty);
        }

        /// <summary>
        /// Asserts that the specified int value matches the expected value.
        /// </summary>
        /// <param name="value">The int value to assert.</param>
        /// <param name="expected">The expected int value.</param>
        /// <param name="message">The exception message.</param>
        public static void AssertCount(this int value, int expected, string message)
        {
            if (value != expected)
            {
                throw new Exception(string.IsNullOrWhiteSpace(message) ? string.Format("Assertion failed: expected <{0}> but was <{1}>.", expected, value) : message);
            }
        }
    }
}
